//
//  QZGoodsVC.m
//  map
//
//  Created by 000 on 16/11/28.
//  Copyright © 2016年 faner. All rights reserved.
//

#import "QZGoodsVC.h"
#import "QZXianyouVC.h"
#import "QZYiWanChengVC.h"

@interface QZGoodsVC ()

@property (nonatomic, strong) UISegmentedControl *segmentBtn;
@property (nonatomic, strong) QZXianyouVC *xianyouVC;
@property (nonatomic, strong) QZYiWanChengVC  *yiwanchengVC;
@property (nonatomic, strong) UIView *xianyouView;
@property (nonatomic, strong) UIView *yiwanchengView;

@end

@implementation QZGoodsVC

- (QZXianyouVC *)xianyouVC
{
    if (_xianyouVC == nil) {
        _xianyouVC = [[QZXianyouVC alloc] init];
    }
    return _xianyouVC;
}
- (QZYiWanChengVC *)yiwanchengVC
{
    if (_yiwanchengVC == nil) {
        _yiwanchengVC = [[QZYiWanChengVC alloc] init];
    }
    return _yiwanchengVC;
}

- (UISegmentedControl *)segmentBtn
{
    if (_segmentBtn == nil) {
        _segmentBtn = [[UISegmentedControl alloc] initWithItems:@[@"现有",@"已完成"]];
        _segmentBtn.selectedSegmentIndex = 0;
        [_segmentBtn addTarget:self action:@selector(switchTable:) forControlEvents:UIControlEventValueChanged];
    }
    return _segmentBtn;
}

- (void)switchTable:(UISegmentedControl *)segmentBtn
{
    if (segmentBtn.selectedSegmentIndex == 0) {
        if (self.yiwanchengView.superview) {
            [self.yiwanchengView removeFromSuperview];
        }
        if (!self.xianyouView.superview) {
            [self.view addSubview:self.xianyouView];
        }
    } else {
        if (self.xianyouView.superview) {
            [self.xianyouView removeFromSuperview];
        }
        if (!self.yiwanchengView.superview) {
            [self.view addSubview:self.yiwanchengView];
        }
    }
}

- (void)viewDidLoad {
    [super viewDidLoad];
//    [self.navigationController.navigationBar setBarTintColor:[UIColor clearColor]];
//    [self.navigationController.navigationBar setBarTintColor:[UIColor redColor]];
    [self.navigationController.navigationBar setTintColor:[UIColor blackColor]];
    self.navigationItem.titleView = self.segmentBtn;
    self.xianyouView = self.xianyouVC.view;
    self.yiwanchengView = self.yiwanchengVC.view;
//    [self.view addSubview:self.yiwanchengView];
    [self.view addSubview:self.xianyouView];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
